import 'package:flutter/material.dart';
import 'package:flutter_ahj_app/app/HttpRequest.dart';
import 'package:flutter_ahj_app/app/jc/JCListView.dart';
import 'package:flutter_ahj_app/app/jc/JCViewModel.dart';
import 'package:flutter_ahj_app/base/basewidget/view/BaseWidget.dart';
import 'package:flutter_ahj_app/base/basewidget/viewmodel/ViewModelProvider.dart';
import 'package:flutter_ahj_app/base/utils/mTopBar.dart';
import 'package:flutter_ahj_app/base/values/SQColor.dart';
import 'package:flutter_ahj_app/base/values/dimens.dart';

 class JCHomeView extends BaseStatefulWidget {
  @override
  State<StatefulWidget> initState() {
    // TODO: implement initState
    // throw UnimplementedError();
    return JCHomeViewState();
  }
}

class JCHomeViewState extends State<JCHomeView> with TickerProviderStateMixin {

  TabController  _tabCtr;
   var _data;

  _getData() {
    HttpRequest.userInfoRequest().listen((result){
      setState(() {
        _data = result;
      });
    },onError: (e){
      
    });
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: MTopBar(
        elevation: 0,
          title: '检查',
          bottom: TabBar(
            controller: _tabCtr,
            isScrollable: false,
            indicatorColor: SQColor.white,
            indicatorWeight: 2,

            indicatorPadding: EdgeInsets.only(bottom: 0),
            labelColor: SQColor.white,
            labelStyle: TextStyle(
              fontSize: Dimens.textSize32,
            ),
            unselectedLabelColor: SQColor.per70White,
            unselectedLabelStyle: TextStyle(
              fontSize: Dimens.textSize28,
            ),
            tabs: [
              Tab(text: '全部'),
              Tab(text: '待检查'),
              Tab(text: '检查中'),
              Tab(text: '已检查'),
            ],
          ))
          .create(),
      body: _bodyView(controller: _tabCtr),
    );
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabCtr = TabController(
      length: 4,
      vsync: this,
    );
    Future.delayed(Duration.zero, () {
      _getData();
    });
  }

  _bodyView({TabController controller}) {
    return TabBarView(controller: controller, children: [
      ViewModelProvider(
          viewModel: JCViewModel(),
          child: JCListView(pageType: JCPageType.qb)),
      ViewModelProvider(
          viewModel: JCViewModel(),
          child: JCListView(pageType: JCPageType.djc)),
      ViewModelProvider(
          viewModel: JCViewModel(),
          child: JCListView(pageType: JCPageType.jcz)),
      ViewModelProvider(
          viewModel: JCViewModel(),
          child: JCListView(pageType: JCPageType.yjc)),
    ]);
  }

}
